<template>
<div>
  <div v-show="personnelEdit && !addAccout" class="mod-config">
    <div class="div-s">
    <el-form :model="params" :label-position="labelPosition" :inline="true" label-width="70px" class="queryFormed">
        <el-row class="row-s">
          <el-col :span="6">
          <el-form-item label="姓名">
            <el-input v-model="params.name" clearable placeholder="请填写姓名" @clear="getDataList"></el-input>
          </el-form-item>
      </el-col>
      <el-col class="col-center" :span="6">
      <el-form-item label="身份证号">
            <el-input v-model="params.idCard" clearable placeholder="请填写身份证号" @clear="getDataList"></el-input>
      </el-form-item>
      </el-col>
      <el-col class="col-center" :span="6">
      <el-form-item label="手机号">
            <el-input v-model="params.mobile" clearable placeholder="请填写手机号" @clear="getDataList"></el-input>
      </el-form-item>
      </el-col>
      <el-col class="col-right" v-if="conceal" :span="6">
      <el-form-item label="学历">
            <el-select v-model="params.academic" placeholder="请选择学历">
                <el-option
                  v-for="item in academics"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
            </el-select>
      </el-form-item>
      </el-col>
       <el-col v-if="conceal" :span="6">
      <el-form-item label="职位">
            <el-input v-model="params.post" placeholder="请填写职位" @clear="getDataList"></el-input>
      </el-form-item>
      </el-col>
      <el-col v-if="conceal" class="col-center" :span="6">
      <el-form-item class="fazheng" label="入职日期">
            <el-date-picker type="date" v-model="params.entryTime" :picker-options="pickerOptionsValidityEndTimeA" placeholder="选择到期日期" style="width:100%"></el-date-picker>
      </el-form-item>
      </el-col>
      <el-col v-if="conceal" class="col-center" :span="6">
      <el-form-item class="fazheng" label="合同到期">
            <el-date-picker type="date" v-model="params.contractExpirationTime" @blur="blurContractExpirationTime" :picker-options="pickerOptionsValidityEndTime" placeholder="选择到期日期" style="width:100%"></el-date-picker>
      </el-form-item>
      </el-col>
      <el-col class="col-right" v-if="conceal" :span="6">
      <el-form-item label="年龄">
           <el-select v-model="params.academicAge" placeholder="请选择年龄">
                <el-option
                  v-for="item in academicsAges"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
      </el-form-item>
      </el-col>
      <el-col v-if="conceal" :span="6">
          <el-form-item label="性别">
            <el-select v-model="params.gender" placeholder="请选择性别">
                <el-option
                  v-for="item in genders"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
      </el-form-item>
      </el-col>
      <el-col v-if="conceal" class="col-center" :span="6">
          <el-form-item label="员工状态">
            <el-select v-model="params.onCompanyFlag" placeholder="请选择状态">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
          </el-form-item>
      </el-col>
      <el-col v-if="conceal" class="col-center" :span="6">
          <el-form-item>
          </el-form-item>
      </el-col>
      <el-col class="col-right" :span="6">
      <el-form-item class="item-all">
      <el-button class="buttonItem" size="mini" plain @click="queryAll()">重 置</el-button>
      <el-button class="buttonItem" size="mini" type="primary" @click="querySeek()">搜 索</el-button>
      <el-button v-if="unfold" @click="clicKunfold()" type="text">展开<i class="el-icon-arrow-down zhankai"></i></el-button>
      <el-button v-if="!unfold" @click="clickPackUp()" type="text">收起<i class="el-icon-arrow-up zhankai"></i></el-button>
      </el-form-item>
      </el-col>
      </el-row>
    </el-form>
    </div>
    <div class="div-e">
      <div class="div-inquire">
        <div class="in-t">
          <div class="in-ts"></div>
          <h3 v-if="!inqerts">人员管理</h3>
          <h3 v-if="inqerts">已删除</h3>
        </div>
        <div v-if="!inqerts" class="div-button">
        <el-button class="div-buttonItemb" size="mini" type="primary" plain icon="iconfont iconexcel" @click="exportXls()">人员导出</el-button>
         <el-upload
         class="upload-transf"
         :action='uploadTransPersonnel()'
         :on-success="onSuccessPersonnel"
         :on-error="onErrorEdit()"
         accept=".xlsx"
         :headers="myHeader"
         :limit="1"
         ref="uploadPersonnel"
         :on-exceed="handleExceed"
         >
         <el-button class="piliangshangchuan" v-if="isAuth('certificate:employeeInfo:save')" type="primary" size="mini" icon="el-icon-upload2 icon-upload2">批量人员上传</el-button>
         </el-upload>
        <el-button class="div-buttonItemb" type="primary" size="mini" icon="el-icon-download"  @click="templateDownloadPersonnel()">人员模板下载</el-button>
        <el-button type="primary" class="div-buttonItemb" size="mini" icon="iconfont iconxinzeng" v-if="isAuth('certificate:employeeInfo:save')" @click="addOrUpdateHandle(null,true)"> 新增</el-button>
        <el-button size="mini"  class="div-buttonItema" plain icon="iconfont iconlajixiang" v-if="isAuth('certificate:employeeInfo:delete')" @click="updateParams(0)"> 已删除</el-button>

        <!-- <el-button class="div-buttonItema" plain v-if="isAuth('certificate:certificateInfo:delete')" size="mini" icon="iconfont iconlajixiang" @click="certificateinfoCrashHandler()">作废列表</el-button> -->
        </div>
        <div v-if="inqerts" class="div-button">
        <el-button type="text" style="color:#6E92E9; float: right;" @click="gotoRouteHandle">返回上级</el-button>
        </div>
      </div>
      <!-- <div class="dingwei">
      <el-form :inline="true" class="queryFormsb">
      <el-form-item>

        <el-input class="seek-s" v-model="params.name" size="medium" clearable placeholder="请输入完整姓名"></el-input>
        <el-button class="buttonItem" type="primary" @click="querySeek()">搜 索</el-button>

        <el-button class="gaojisousuo" type="primary" size="small" icon="iconfont iconsoushuo" @click="queryHandle()">高级搜索</el-button>
        <el-button class="gaojisousuo" type="primary" size="small" icon="el-icon-refresh-right" @click="queryAll()">重置</el-button>
        <el-button class="gaojisousuo" size="small" icon="iconfont iconlajixiang" v-if="isAuth('certificate:certificateInfo:list')" type="danger" @click="updateParams(0)">已删除</el-button>
        <el-button class="gaojisousuo" type="primary" size="small" plain icon="iconfont iconxinzeng" v-if="isAuth('certificate:certificateInfo:save')" @click="addOrUpdateHandle()"> 新增</el-button>
        <el-button class="gaojisousuo" size="small" icon="iconfont iconxiazai" @click="templateDownloadPersonnel()">人员模板下载</el-button>
        <el-upload
         class="upload-transf"
         :action='uploadTransPersonnel()'
         :on-success="onSuccessPersonnel"
         :on-error="onErrorEdit()"
         accept=".xlsx"
         :headers="myHeader"
         :limit="1"
         ref="uploadPersonnel"
         :on-exceed="handleExceed"
         >
         <el-button class="piliangshangchuan" size="small" icon="el-icon-upload2 icon-upload2">批量人员上传</el-button>
         </el-upload>
      </el-form-item>
    </el-form>
  </div> -->
    <el-table
      :data="dataList"
      @sort-change='sort_change'
      :max-height="tableHeight"
      :header-cell-style="{background:'#F5F7FA'}"
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">
      <!-- <el-table-column
        type="index"
        label="序号"
        width="60">
      </el-table-column> -->
      <el-table-column
        prop="deptName"
        align="center"
        sortable='custom'
        min-width="80"
        label="所属部门">
      </el-table-column>
      <el-table-column
        prop="name"
        min-width="80"
        sortable='custom'
        align="center"
        label="姓名">
      </el-table-column>
      <el-table-column
        prop="roleName"
        min-width="80"
        sortable='custom'
        align="center"
        label="角色">
      </el-table-column>
      <el-table-column
        prop="post"
        align="center"
        sortable='custom'
        min-width="60"
        label="职位"
        :formatter="dateFormats"
      >
      </el-table-column>
      <el-table-column
        prop="gender"
        align="center"
        sortable='custom'
        min-width="60"
        label="性别"
        :formatter="genderFormat">
      </el-table-column>
      <el-table-column
        prop="idCard"
        align="center"
        min-width="200"
        sortable='custom'
        label="身份证号"
        :formatter="dateFormats">
      </el-table-column>
      <el-table-column
        prop="mobile"
        min-width="160"
        sortable='custom'
        align="center"
        :formatter="dateFormats"
        label="手机号">
      </el-table-column>
      <el-table-column
        prop="academic"
        min-width="100"
        sortable='custom'
        align="center"
        :formatter="dateFormats"
        label="学历">
      </el-table-column>
      <el-table-column
        prop="entryTime"
        min-width="100"
        align="center"
        sortable='custom'
        label="入职时间"
        :formatter="dateFormats">
      </el-table-column>
      <el-table-column
        prop="contractExpirationTime"
        min-width="120"
        sortable='custom'
        align="center"
        label="合同到期日期"
        :formatter="dateFormats">
      </el-table-column>
      <el-table-column
        align="center"
        min-width="200"
        label="操作">
        <template slot-scope="scope">
          <el-button v-if="isAuth('tenant:employee:saveByEmployee') && scope.row.accountCreateFlag === 0" style="color:#53b4ff;" type="text"  size="mini" @click="clickAddAccount(scope.row)">添加子账号</el-button>
          <el-button style="color:#53b4ff;" type="text" size="mini" @click="detailsHandle(scope.row)">查看</el-button>
          <span v-if="isAuth('certificate:employeeInfo:update')" style="color:#E8E8E8;">|</span>
          <el-button class="button-e" v-if="scope.row.status === 1 && isAuth('certificate:employeeInfo:update')" type="text" style="color:#53b4ff;" size="mini" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
          <span style="color:#E8E8E8;"  v-if="scope.row.status === 1 && isAuth('certificate:employeeInfo:delete')">|</span>
          <el-button class="button-s" v-if="scope.row.status === 1 && isAuth('certificate:employeeInfo:delete')" type="text" style="color:#e83e25;" size="mini" @click="deleteHandle(scope.row.id)">删除</el-button>

          <el-button class="button-s" v-if="scope.row.status === 0 && isAuth('certificate:employeeInfo:delete')" type="text" style="color:#fc8e2d;" size="mini" @click="recoverHandle(scope.row.id)">还原</el-button>
        </template>
      </el-table-column>
    </el-table>
  <!-- 批量结果 -->
  <el-dialog
  title="人员批量上传录入结果"
  :visible.sync="matchingDialogVisible"
  width="50%"
  center>
  <span>
  <div class="consequence">
    <div class="consequence-s">
     <div>
       <i class="el-icon-success chenggong"></i>{{this.success}}人导入成功
       </div>
    </div>
    <div class="consequence-e">
    <div>
      <i class="el-icon-error shibai"></i>{{this.fail}}人导入失败
      </div>
    </div>
  </div>
  <div>
    <el-table
    :data="tableData"
    height="350"
    border
    style="width: 100%">
    <el-table-column
    align="center"
      type="index"
      header-align="center"
      label="#"
      width="40">
    </el-table-column>
    <el-table-column
      prop="name"
      header-align="center"
      align="center"
      label="名字"
      width="100"
      >
    </el-table-column>
    <el-table-column
      prop="idCard"
      header-align="center"
      align="center"
      label="身份证号码">
    </el-table-column>
    <el-table-column
      prop="msg"
      header-align="center"
      align="center"
      label="失败原因">
    </el-table-column>
    <el-table-column
      prop="filePath"
      label="部门"
      header-align="center"
      align="center"
      width="200">
    </el-table-column>
  </el-table>
  </div>
  </span>
  <span slot="footer" class="dialog-footer">
    <el-button type="primary" @click="matchingDialogVisible = false">关 闭</el-button>
  </span>

<!-- 添加子账号 -->
</el-dialog>
<!--    <el-dialog
    title="添加子账号"
    width="30%"
    class="dialogForm"
    :visible.sync="addAccout"
    append-to-body
    >
      <el-form :model="borrowForm" :rules="borrowFormRule" ref="borrowForm" label-width="100px">
        <el-row>
          <el-col :span="22">
            <el-form-item label="姓名">
              <el-input readonly v-model="borrowForm.name" ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="22">
            <el-form-item label="选择角色">
              <el-select readonly v-model="borrowForm.roleId">
                <el-option
                  v-for="item in roleOptionsList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="22">
            <el-form-item label="登录账号">
              <el-input readonly v-model="borrowForm.mobile"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="22">
            <el-form-item label="登录密码" prop="password">
              <el-input v-model="borrowForm.password"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="addAccout = false">取 消</el-button>
        <el-button size="small" type="primary" plain @click="borrowFormSubmit()">确 定</el-button>
      </div>
    </el-dialog>-->

    <el-pagination
      background
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[5, 10, 20, 50, 100, 200]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, prev, pager, next, sizes, jumper">
    </el-pagination>
    </div>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update  @clickGetList="clickGetList" v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" :cache-data="addOrUpdateCacheData" @setCacheData="setCacheData"></add-or-update>
    <employee-details v-if="detailsVisible" ref="employeeDetails"></employee-details>
    <query-model v-if="queryModelVisible" ref="queryModel" @refreshDataList="setParams"></query-model>
  </div>
  <personnel-type :rowName="rowName" :rowId="rowId" v-if="!personnelEdit && !addAccout"></personnel-type>
  <add-account ref="addAccountRefs" v-show="addAccout" @goBack="hideAddAccount" @refreshData="queryAll"></add-account>
</div>
</template>

<script>
  import merge from 'lodash/merge'
  import AddOrUpdate from './em/employee-add-or-update'
  import EmployeeDetails from './em/employee-details'
  import QueryModel from './em/query-model'
  import PersonnelType from '../certificate/certinfo/personnel-type.vue'
  import { eventBus } from '../../../../eventBus'
  import { isAuth } from '../../../utils'
  import {accountColorList} from '../../../api/customer/commom'

import Vue from 'vue'
  import {getRoleList} from '../../../api/customer/role'
  import AuthorizationForm from '../customer/Component/AuthorizationForm'
import FunctionAuthorization from '../customer/Component/FunctionAuthorization'
import DataAuthorization from '../customer/Component/DataAuthorization'
  import AddAccount from './components/AddAccount'
export default {
    data () {
      return {
        // 角色选项框数据
        roleOptionsList: [],
        // 角色颜色配置
        colorOption: accountColorList,
        personnelEdit: true,
        labelPosition: 'right',
        conceal: false,
        userName: '',
        kiveList: false,
        unfold: true,
        addAccout: false,
        inqerts: false,
        heightis: 263,
        matchingDialogVisible: false,
        queryModelVisible: false,
        detailsVisible: false,
        dataForm: {
          key: ''
        },
        dataList: [],
        options: [{
          value: 1,
          label: '在职'}, {
            value: 0,
            label: '离职'
          }
        ],
        input1: '',
        pageIndex: 1,
        pageSize: 20,
        rowName: '',
        rowId: '',
        inOrder: '',
        orderBy: '',
        totalPage: 0,
        maxAge: '',
        minAge: '',
        dataListLoading: false,
        dataListSelections: [],
        pickerOptionsValidityEndTime: {
          disabledDate: (time) => {
            return time.getTime() < this.params.entryTime
          }
        },
        pickerOptionsValidityEndTimeA: {},
        addOrUpdateVisible: false,
        academics: [
          {
            value: '',
            label: '全部'
          },
          {
            value: '博士',
            label: '博士'
          }, {
            value: '硕士',
            label: '硕士'
          }, {
            value: '本科',
            label: '本科'
          }, {
            value: '专科',
            label: '专科'
          }, {
            value: '高职高专',
            label: '高职高专'
          }, {
            value: '中专',
            label: '中专'
          }, {
            value: '高中',
            label: '高中'
          }, {
            value: '初中',
            label: '初中'
          }, {
            value: '小学',
            label: '小学'
          }, {
            value: '其他',
            label: '其他'
          }],
        genders: [
          {
            value: '',
            label: '全部'
          },
          {
            value: 1,
            label: '男'
          },
          {
            value: 2,
            label: '女'
          }
        ],
        academicsAges: [
          {
            value: '',
            label: '全部'
          }, {
            value: 1,
            label: '20岁以下'
          },
          {
            value: 2,
            label: '20-30岁'
          },
          {
            value: 3,
            label: '31-40岁'
          },
          {
            value: 4,
            label: '40岁以上'
          }
        ],
        params: {
          name: '',
          idCard: '',
          mobile: '',
          academic: '',
          jobGrade: '',
          entryTime: '',
          gender: '',
          onCompanyFlag: '',
          contractExpirationTime: '',
          status: '',
          post: '',
          academicAge: ''
        },
        tableData: [],
        tableHeight: 0,
        success: '',
        fail: '',
        addOrUpdateCacheData: {
          id: 0,
          deptId: '',
          tenantId: '',
          name: '',
          idCard: '',
          gender: '',
          mobile: '',
          academic: '',
          jobGrade: '',
          entryTime: '',
          contractExpirationTime: '',
          remark: '',
          post: '',
          schoolProfession: '',
          marriageFlag: '',
          graduateTime: '',
          socialSecurityFlag: 0,
          socialSecurityTime: '',
          directorFlag: 1,
          directorFor: '',
          companyEndTime: '',
          onCompanyFlag: 1
        }
      }
    },
    components: {
      AddAccount,
      DataAuthorization,
      FunctionAuthorization,
      AuthorizationForm,
      AddOrUpdate,
      QueryModel,
      EmployeeDetails,
      PersonnelType
    },
    mounted () {
      // this.$nextTick(() => {
      //       this.tableHeight = window.innerHeight - 240;
      //       //后面的50：根据需求空出的高度，自行调整
      //   })
      eventBus.$on('employee', (msg) => {
        this.kiveList = msg
        this.clickKive()
      })

      if (this.$route.params.skipPushE === true) {
        this.clickPushE()
      }
      if (this.$route.skipPushD === true) {
        this.clickPushD()
      }
      if (this.$route.params.skipPushI === true) {
        this.clickPushI()
      }
      if (this.$route.params.skipPushT === true) {
        this.clickPushT()
      }
      if (this.$route.params.skipMale === true) {
        this.clickskipMale()
      }
      if (this.$route.params.skipFemale === true) {
        this.clickskipFemale()
      }
    },
    created () {
      this.getUserName()
      // this.showNotice()
      this.clickPackUp()
      this.params.status = 1
      this.getDataList()
      // this.querySeek()
    },
    computed: {
      myHeader () {
        return {
          'token': Vue.cookie.get('token')
        }
      }

    },
    watch: {
      $route: {
        handler: function (val, oldVal) {
          if (val.params.skipPushE === true) {
            this.clickPushE()
          }
          if (val.params.skipPushD === true) {
            this.clickPushD()
          }
          if (val.params.skipPushI === true) {
            this.clickPushI()
          }
          if (val.params.skipPushT === true) {
            this.clickPushT()
          }
      // skipMale:true,
      // skipFemale:true,
          if (val.params.skipMale === true) {
            this.clickskipMale()
          }
          if (val.params.skipFemale === true) {
            this.clickskipFemale()
          }
        },
    // 深度观察监听
        deep: true
      },
      params () {
        this.$nextTick(() => {
          this.getDataList()
        })
      }
    },
    methods: {
      setCacheData (data) {
        Object.keys(data).forEach((key) => { this.addOrUpdateCacheData[`${key}`] = data[`${key}`] })
      },
      isAuth (auth) {
        return isAuth(auth)
      },
      getRoleList () {
        getRoleList(({data}) => {
          this.roleOptionsList = data
        })
/*        this.$http({
          url: this.$http.adornUrl('/ent/role/paging'),
          method: 'post',
          data: this.$http.adornData({
            'conditions': {
              'name': ''
            },
            'inOrder': '',
            'orderBy': '',
            'pageNum': this.pageIndex,
            'pageSize': this.pageSize
          })
        }).then(({data: res}) => {
          if (res && res.code === 0) {
            this.roleOptionsList = res.data.records
          } else {

          }
        }) */
      },
      exportXls () {
        this.$http({
          url: this.$http.adornUrl('/certificate/employeeInfo/export'),
          method: 'get',
          responseType: 'blob', // 防止返回乱码
/*           params: this.$http.adornParams(merge(this.params, {
            'status': this.flag ? 'crash' : this.params.status
          })), */
          showLoading: true
        }).then(({data}) => {
          if (data) {
            const link = document.createElement('a')
            let blob = new Blob([data], {type: 'application/vnd.ms-excel'})
            link.style.display = 'none'
            link.href = URL.createObjectURL(blob)
            let fileName = '人员导出统计.xls'
            link.setAttribute('download', fileName)
            link.download = fileName // 下载的文件名
            document.body.appendChild(link)
            link.click()
            document.body.removeChild(link)
          }
        })
      },
      blurContractExpirationTime () {
        if (this.params.contractExpirationTime !== '') {
          this.pickerOptionsValidityEndTimeA = {
            disabledDate: (time) => {
              return time.getTime() > this.params.contractExpirationTime
            }
          }
        } else {
          this.pickerOptionsValidityEndTimeA = {}
        }
      },
      clickAddAccount (row) {
        this.$refs.addAccountRefs.setAddData(row)
        this.addAccout = true
/*        if (row.mobile) {
          this.borrowFormId = row.id
          this.borrowForm.mobile = row.mobile
          this.borrowForm.name = row.name
          this.borrowForm.roleId = ''
          this.getRoleList()
          this.addAccout = true
        } else {
          this.$message.warning('电话号码为空，需先修改手机号码')
        } */
      },
      getUserName () {
        this.$http({
          url: this.$http.adornUrl('/sys/user/info'),
          method: 'get',
          params: {}
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.userName = data.user.name
          }
        })
      },
      hideAddAccount () {
        this.addAccout = false
      },
      clickPushE () {
        this.params.academicAge = 1
        this.querySeek()
      },
      clickPushD () {
        this.params.academicAge = 2
        this.querySeek()
      },
      clickPushI () {
        this.params.academicAge = 3
        this.querySeek()
      },
      clickPushT () {
        this.params.academicAge = 4
        this.querySeek()
      },
      clickskipMale () {
        this.params.gender = 1
        this.querySeek()
      },
      clickskipFemale () {
        this.params.gender = 2
        this.querySeek()
      },
      clickKive () {
        if (this.kiveList) {
          this.personnelEdit = true
        }
      },
      adjustTableHeight () {
        this.$nextTick(() => {
          this.tableHeight = window.innerHeight - this.heightis
          // 后面的50：根据需求空出的高度，自行调整
        })
      },
      clicKunfold () {
        this.conceal = true
        this.unfold = false
        this.heightis = 375
        this.adjustTableHeight()
      },
      clickPackUp () {
        this.conceal = false
        this.unfold = true
        this.heightis = 266
        this.adjustTableHeight()
      },
      gotoRouteHandle () {
        this.inqerts = false
        this.params.status = 1
        this.getDataList()
      },
      uploadTransPersonnel () {
        return this.$http.adornUrl(`/certificate/employeeInfo/batchSave`)
      },
      onSuccessPersonnel (response, file, fileList) {
        console.log(response)
        this.$refs.uploadPersonnel.clearFiles()
        if (response.code === 0) {
          this.$message.success('上传成功')
          this.tableData = response.data
          this.fail = response.fail
          this.success = response.success
          this.matchingDialogVisible = true
          this.getDataList()
        } else {
          this.$message.error(response.msg)
          this.$refs.uploadPersonnel.clearFiles()
        }
      },
      handleExceed (files, fileList) {
        this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`)
      },
      templateDownloadPersonnel () {
        window.location.href = window.SITE_CONFIG.remoteUrl + 'others/employee-Template.xlsx'
      },
      sort_change (column) {
      // console.log(column);
        this.orderBy = column.prop
      // console.log(this.orderBy);
        if (column.order === 'ascending') {
          this.inOrder = 'asc'
        }
        if (column.order === 'descending') {
          this.inOrder = 'desc'
        }
        this.getDataListList()
      },
      // 搜索
      querySeek () {
        this.getDataListList()
      },
      genderFormat (row, column) {
        if (row.gender === 2) {
          return '女'
        } else {
          return '男'
        }
      },
      dateFormats (row, column, cellValue, index) {
        if (!cellValue) {
          return '-'
        } else {
          return cellValue
        }
      },
      setParams (params) {
        this.params = params
      },
      updateParams (status) {
        this.inqerts = true
        this.params.status = status
        this.getDataList()
      },
      dateFormat (row, column, cellValue, index) {
        return cellValue ? cellValue.substring(0, 10) : ''
      },
      onErrorEdit () {
        console.log('错误')
      },
      clickAppear () {
        this.personnelEdit = true
      },
      clickGetList () {
        this.getDataList()
      },
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/certificate/employeeInfo/list'),
          method: 'get',
          params: this.$http.adornParams(merge(this.params, {
            'page': this.pageIndex,
            'limit': this.pageSize,
            'inOrder': this.inOrder,
            'orderBy': this.orderBy
          }))
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      getDataListList () {
        if (this.params.academicAge === '') {
          this.minAge = ''
          this.maxAge = ''
        }
        if (this.params.academicAge === 1) {
          this.minAge = 1
          this.maxAge = 19
        }
        if (this.params.academicAge === 2) {
          this.minAge = 20
          this.maxAge = 30
        }
        if (this.params.academicAge === 3) {
          this.minAge = 31
          this.maxAge = 40
        }
        if (this.params.academicAge === 4) {
          this.minAge = 41
          this.maxAge = 100
        }
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/certificate/employeeInfo/list'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'deptId': this.deptId,
            'inOrder': this.inOrder,
            'orderBy': this.orderBy,
            'name': this.params.name,
            'onCompanyFlag': this.params.onCompanyFlag,
            'gender': this.params.gender,
            'maxAge': this.maxAge,
            'post': this.params.post,
            'minAge': this.minAge,
            'idCard': this.params.idCard,
            'mobile': this.params.mobile,
            'academic': this.params.academic,
            'jobGrade': this.params.jobGrade,
            'entryTime': this.$dateFormat(this.params.entryTime),
            'contractExpirationTime': this.$dateFormat(this.params.contractExpirationTime),
            'status': this.params.status
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataListList()
      },
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataListList()
      },
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },
      queryHandle () {
        this.queryModelVisible = true
        this.$nextTick(() => {
          this.$refs.queryModel.init()
        })
      },
      detailsHandle (row) {
        this.personnelEdit = false
        this.rowName = row.name
        this.rowId = row.id
        // this.$nextTick(() => {
        //   this.$refs.employeeDetails.init(id)
        // })
      },
      addOrUpdateHandle (id) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.addOrUpdate.init(id)
        })
      },
      recoverHandle (id) {
        var ids = id ? [id] : this.dataListSelections.map(item => {
          return item.id
        })
        this.$confirm('确定要还原此条信息吗?', '提示', {
          confirmButtonText: '还原',
          cancelButtonText: '取消',
          confirmButtonClass: 'el-button--warning',
          center: true
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl('/certificate/employeeInfo/recover'),
            method: 'post',
            data: this.$http.adornData(ids, false)
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.getDataList()
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      },
      deleteHandle (id) {
        // var ids = id ? [id] : this.dataListSelections.map(item => {
        //   return item.id
        // })
        this.$confirm('确定要把此条信息放入垃圾箱吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          confirmButtonClass: 'el-button--warning',
          center: true
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl('/certificate/employeeInfo/delete/' + id),
            method: 'post'
            // data: this.$http.adornData({
            //     'id':id
            //   })
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.getDataList()
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      },
      // showNotice(){
      //   if(!this.$store.state.bizz.infoflag){
      //     this.$confirm(`<p><svg class="icon svg-icon" aria-hidden="true"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#iconwanshanziliao"></use></svg></p>请完善企业信息`, '', {
      //       confirmButtonText: '去完善',
      //       cancelButtonText: '下次再说',
      //       confirmButtonClass: 'el-button--warning',
      //       dangerouslyUseHTMLString: true,
      //       showClose: false,
      //       center: true
      //     }).then(() => {
      //       this.$router.push({name:'company-info'})
      //     }).catch(() => {
      //       this.$router.push({name:'home'})
      //     });
      //   }
      // },
      // 全部
      queryAll () {
        if (this.inqerts) {
          this.params = {
            status: 0,
            name: '',
            idCard: '',
            mobile: '',
            academic: '',
            jobGrade: '',
        // entryTime: '',
            minAge: '',
            maxAge: '',
            onCompanyFlag: '',
        // contractExpirationTime: '',
            post: '',
            gender: '',
            academicAge: ''
          }
        } else {
          this.params = {
            status: 1,
            name: '',
            idCard: '',
            mobile: '',
            academic: '',
            jobGrade: '',
        // entryTime: '',
            minAge: '',
            maxAge: '',
            onCompanyFlag: '',
        // contractExpirationTime: '',
            post: '',
            gender: '',
            academicAge: ''
          }
        }

        this.getDataList()
      }
    }
  }
</script>
<style lang="scss" scoped>
.mod-config{
  padding: 15px !important;
  background-color: #F5F7FA !important;
}
/deep/.chongzhi-s{
  i{
    font-size: 16px;
  }
}
.div-s{
  width: 100%;
  background-color: #FFFFFF;
}
.div-e{
  width: 100%;
  background-color: #FFFFFF;
  padding-left: 15px;
  padding-right: 15px;
  padding-bottom: 15px;
  margin-top: 15px;
  overflow: hidden;
}
  .queryFormed .el-form-item{
    margin-top: 8px;
    margin-bottom: 8px;
  }
  /deep/.queryFormed .el-form-item{
    .el-select .el-input__inner{
    height: 36px!important;
    padding-right: 15px!important;
    padding-left: 15px!important;
    }
    .el-input--suffix .el-input__inner{
    padding-right: 15px!important;
    padding-left: 15px!important;
    }
  }
  .row-s{
  /deep/.el-col{
    display: flex;
    // justify-content: center;
    align-items: center;
    padding-left: 15px;
    padding-right: 15px;
  }
}
/deep/.col-right{
.el-form-item{
margin-left: auto!important;
}
}
/deep/.el-col{
    .fazheng{
    .el-form-item__content{
    .el-input--suffix{
    .el-input__inner{
      padding-right: 0px!important;
      padding-left: 30px!important;
       }
     }
   }
 }
}
/deep/.col-center{
  display: flex;
  align-items: center;
  justify-content: center;
}

.div-inquire{
  width: 100%;
  height: 45px !important;
  background-color: #ffffff;
  margin-bottom: 10px;
  // display: flex;
  // align-items: center;
}
.div-button{
  width: 40%;
  float: right;
  margin-top: 15px;
  // display: flex;
  // align-items: center;
  // justify-content: center;
}
/deep/.div-buttonItemb{
  float: right;
  margin-left: 8px;
    font-size: 14px;
  i{
    font-size: 14px;
  }
}
/deep/.div-buttonItema{
  float: right;
  // margin-right: 8px;
  font-size: 14px;
  i{
    font-size: 14px;
  }
}
.in-t{
  width: 50%;
  float: left;
  height: 45px;
  display: flex;
  align-items: center;
  // margin-top: 15px;
  h3{
    float: left;
    font-size: 16px;
    margin: 0px !important;
    padding: 0px !important;
    color: #000000;
  }
}
.in-ts{
  width: 5px;
  height: 18px;
  float: left;
  margin-right: 8px;
  background: #6E92E9;
}
// 分页控制
.el-pagination.is-background .el-pager li:not(.disabled).active{
    background-color: #ffffff !important;
    border: 1px solid #6E92E9;
    // boder: ;
    color: #6E92E9 !important;
  }
  .seek-s{
  width: 230px;
  float: left;
  }
  /deep/ .button-s{
    margin-left: 0px!important;
  }
  /deep/ .button-e{
    margin-left: 0px!important;
  }
  .icon-upload2{
    font-size: 16px;
  }
  /deep/.sousuo{
    margin-left: 15px;
    // margin-top: 2px;
    float: left;
    font-size: 14px !important;
    i{
      font-size: 16px;
    }
  }
/deep/.buttonItem{
  // float: left;
  // margin-left: 15px;
  font-size: 14px !important;
  i{
    font-size: 16px;
  }
  }
/deep/.gaojisousuo{
  margin-left: 14px;
  font-size: 14px !important;
  i{
    font-size: 16px;
  }
}
/deep/
.el-dialog__header{
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
.el-dialog__title{
  font-size: 16px !important;
  font-weight: 700 !important;
  padding: 20px !important;
}
}
/deep/.piliangshangchuan{
  // font-size: 14px !important;
  font-size: 14px;
  i{
    font-size: 14px;
  }
}
.picturess{
  font-size: 14px;
}
.consequence{
    width: 100%;
    background-color: aqua;
    height: 60px;
    text-align: center;
    background-color: #FAFAFAFF;
    .consequence-s{
    div{
      height: 15px;
      margin-top: 15px;
    }
    .chenggong{
    width: 20px;
    color: #09AB6E;
    margin-right: 10px;
    }
    float: left;
     width: 50%;
     height: 60px;
     font-size: 15px;
     border: 1px solid #ccc;
    text-align: center;
    }
    .consequence-e{
      div{
      height: 15px;
      margin-top: 15px;
    }
    .shibai{
    width: 20px;
    color: red;
    margin-right: 10px;
      }
     float: left;
     width: 50%;
     height: 60px;
     text-align: center;
     font-size: 15px;
     border: 1px solid #ccc;
    }
  }
.upload-transf{
  float: right;
  margin-left: 8px;
  }
  .icon-upload2{
    font-size: 16px;
  }
  .queryFormsb .el-form-item{
    margin-top: 8px;
    margin-bottom: 10px;
  }
  .el-button--danger {
    color: #f56c6c;
    background-color: #fff;
    border-color: #f56c6c;
  }
  // .el-button--primary{

  //   background-color: #fc8e2d;
  //    border-color: #fc8e2d;
  // }
</style>
